
package com.amigo.online.provider.user.service.impl;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.amigo.online.common.param.dto.user.SuggestDto;
import com.amigo.online.common.param.result.UserInfo;
import com.amigo.online.provider.user.common.GlobalController;
import com.amigo.online.provider.user.mapper.SuggestMapper;
import com.amigo.online.provider.user.model.entity.Suggest;
import com.amigo.online.provider.user.service.SuggestService;

@Service
public class SuggestServiceImpl implements SuggestService {

    @Autowired
    private SuggestMapper suggestMapper;

    @Override
    public boolean addSuggest(SuggestDto dto) {
        UserInfo nowUser = GlobalController.getNowUser();
        Suggest suggest = new Suggest();
        BeanUtils.copyProperties(dto, suggest);
        suggest.setCreatedTime(System.currentTimeMillis() / 1000);
        suggest.setUser_id(nowUser.getId());
        return suggestMapper.insertSelective(suggest) > 0;
    }

}
